package br.smd.ufc;

import java.util.Locale;

import org.mapview.R;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

import android.app.Activity;
import android.content.Context;
import android.location.Geocoder;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class TesteMapa extends MapActivity implements OnClickListener{
	LocationManager lm;
	Geocoder geocoder;
	MapView map;
	MapController mapControl;
	
	Button btBuscar;
	
	EditText Tlatitude, Tlongitude;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        
        lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
        
        map = (MapView) findViewById(R.id.meuMapa);
        map.setSatellite(false);
        
        mapControl = map.getController();
        mapControl.setZoom(17);
        
        btBuscar = (Button) findViewById(R.id.button1);
        btBuscar.setOnClickListener(this);
        
        Tlatitude = (EditText) findViewById(R.id.editTextLatitude);
        Tlongitude = (EditText) findViewById(R.id.editTextLongitude);
        
    }

	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}

	public void onClick(View v) {
		if(v == btBuscar){
			Double lat = Double.parseDouble(Tlatitude.getText().toString());
			Double lon = Double.parseDouble(Tlongitude.getText().toString());
			
			GeoPoint point = new GeoPoint(lat.intValue(),lon.intValue());
			mapControl.animateTo(point);
			
		}
		
	}
}